
<!DOCTYPE html><html><head><meta charset="utf-8"><meta content="webkit" name="renderer"/><meta http-equiv="X-UA-Compatible"
content="IE=edge"><meta name="keywords" content="PoweredByJeeSiteV4.0"/><meta http-equiv="Cache-Control"
content="no-cache, no-store, must-revalidate"/><meta name="description" content="PoweredByJeeSiteV4.0"/><meta
content="no-cache" http-equiv="Pragma"/><meta http-equiv="Expires" content="0"/><meta
content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<title>用户选择 - 微沃wewoo</title>
<script src="/wewoo/global.min.js?ctx=/wewoo/a"></script>
<script src="/wewoo/static/jquery/jquery-1.12.4.min.js"></script>
<script src="/wewoo/static/jquery/jquery-migrate-1.4.1.min.js"></script>
<!--[if lt IE 9]><script src="/wewoo/static/common/h5fix.min.js"></script><![endif]-->
<link rel="stylesheet" href="/wewoo/static/fonts/font-icons.min.css">
<link rel="stylesheet" href="/wewoo/static/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/wewoo/static/select2/4.0/select2.css?V1.0-12221301">
<link rel="stylesheet" href="/wewoo/static/icheck/1.0/minimal/grey.css?V1.0-12221301">
<link rel="stylesheet" href="/wewoo/static/jqGrid/4.7/css/ui.jqgrid.css?V1.0-12221301">
<link rel="stylesheet" href="/wewoo/static/adminlte/css/AdminLTE.min.css?V1.0-12221301">
<link rel="stylesheet" href="/wewoo/static/common/jeesite.css?V1.0-12221301">
<link rel="stylesheet" href="/wewoo/static/common/common.css?V1.0-12221301">
</head><body class="hold-transition ">
<div class="wrapper"><div class="main-content">
	<div class="box box-main">
		<div class="box-body">
<#form:form id="searchForm" model="${ztQuan}" action="${ctx}/ztGoodsquan/formList" method="post" class="form-inline hide"

					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">

				<div class="form-group">

					<label class="control-label">${text('券名')}：</label>

					<div class="control-inline">

						<#form:input path="name" maxlength="200" class="form-control width-120"/>

					</div>

				</div>
				
				<div class="form-group">

					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>

					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>

				</div>

			</#form:form>
			
			<div class="row">
				<div class="col-xs-10 pr10">
					<table id="dataGrid"></table>
					<div id="dataGridPage"></div>
				</div>
				<div class="col-xs-2 pl0">
					<div id="selectData" class="tags-input"></div>
				</div>
				
				
				<div class="layui-layer-btn"><a class="layui-layer-btn0" href="#" onClick="getData()"><i class="fa fa-check"></i> 确定</a>
				
				
				
				
				<a class="layui-layer-btn1" href="#"
						onclick="js.closeCurrentTabPage()">
						<i class="fa fa-close"></i> 关闭
					</button>
				
				</div><span class="layui-layer-resize"></span></div>
				
			</div>
		</div>
	</div>
</div>
</div>

<a id="scroll-up" href="#" class="btn btn-sm"><i class="fa fa-angle-double-up"></i></a>
<script src="/wewoo/static/bootstrap/js/bootstrap.min.js"></script>
<script src="/wewoo/static/select2/4.0/select2.js?V1.0-12221301"></script>
<script src="/wewoo/static/select2/4.0/i18n/zh_CN.js?V1.0-12221301"></script>
<script src="/wewoo/static/layer/3.1/layer.js?V1.0-12221301"></script>
<script src="/wewoo/static/my97/WdatePicker.js?V1.0-12221301"></script>
<script src="/wewoo/static/jqGrid/4.7/js/jquery.jqGrid.js?V1.0-12221301"></script>
<script src="/wewoo/static/jqGrid/4.7/js/jquery.jqGrid.extend.js?V1.0-12221301"></script>
<script src="/wewoo/static/jqGrid/4.7/js/i18n/zh_CN.js?V1.0-12221301"></script>
<script src="/wewoo/static/common/jeesite.js?V1.0-12221301"></script>
<script src="/wewoo/static/common/i18n/jeesite_zh_CN.js?V1.0-12221301"></script>
<script src="/wewoo/static/common/common.js?V1.0-12221301"></script>


<script>
var selectData = JSON.parse(js.decodeUrl('%7B%7D')),
selectNum = 0, dataGrid = $('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
{header:'${text('优惠券类型')}', name:'type', index:'a.type', width:100, align:"center", formatter: function(val, obj, row, act){
	return js.getDictLabel(${@DictUtils.getDictListJson('zt_quan_type')}, val, '${text('活动优惠券')}', true);
}},
{header:'${text('优惠券券名')}', name:'name',index:'a.name',  width:150, align:"center"},
{header:'${text('图片')}', name:'img',  width:110, align:"center",formatter: function(val, obj, row, act){
	return '<img style="width:50px;height:40px;" src="'+val+'"></img>';
}},
{header:'${text('优惠券优惠金额')}', name:'price', index:'a.price', width:160, align:"center"},


{header:'${text('剩余数量')}', name:'overCount', index:'a.over_count', width:110, align:"center"},

{header:'${text('到期时间')}', name:'toTime', index:'a.to_time', width:160, align:"center"},
{header:'${text('状态')}', name:'usestatus', index:'a.usestatus', width:90, align:"center", formatter: function(val, obj, row, act){
	return js.getDictLabel(${@DictUtils.getDictListJson('zt_usestatus_type')}, val, '${text('有效')}', true);
}},

{header:'行数据', name:'rowData', hidden:true, formatter: function(val, obj, row, act){
	return JSON.stringify(row);
}}
	],
	autoGridHeight: function(){
		var height = $(window).height() - $('#searchForm').height() - $('#dataGridPage').height() - 73;
		$('.tags-input').height($('.ui-jqgrid').height() - 10);
		return height;
	},
	showCheckbox: 'true' == 'true',
	multiboxonly: false, // 单击复选框时再多选
	
	   ajaxSuccess: function(data){
		  
		 $.each(selectData, function(key, value){
			//alert(key);
			dataGrid.dataGrid('setSelectRow', key);
		});
		initSelectTag(); 
	},   
	
	
	
	onSelectRow: function(id, isSelect, event){
		
		if ('true' == 'true'){
			if(isSelect){
				
				selectData[id] = JSON.parse(dataGrid.dataGrid('getRowData', id).rowData);
			}else{
				
				delete selectData[id];
			}
		}else{
			selectData = {};
			selectData[id] = JSON.parse(dataGrid.dataGrid('getRowData', id).rowData);
		}
		initSelectTag();
	},
	onSelectAll: function(ids, isSelect){
		if ('true' == 'true'){
			for (var i=0; i<ids.length; i++){
				if(isSelect){
					selectData[ids[i]] = JSON.parse(dataGrid.dataGrid('getRowData', ids[i]).rowData);
				}else{
					delete selectData[ids[i]];
				}
			}
		}
		initSelectTag();
	},
	ondblClickRow: function(id, rownum, colnum, event){
		if ('true' != 'true'){
			js.layer.$('#' + window.name).closest('.layui-layer')
				.find(".layui-layer-btn0").trigger("click");
		}
		initSelectTag();
	}
});
function initSelectTag(){
	
	selectNum = 0;
	var html = [];
	$.each(selectData, function(key, value){
		
		selectNum ++;
		html.push('<span class="tag" id="'+key+'_tags-input"><span>'+value.name+' </span>'
			+ '<a href="#" onclick="removeSelectTag(\''+key+'\');" title="取消选择">x</a></span>');
	});
	html.unshift('<div class="title">当前已选择<span id="selectNum">'+selectNum+'</span>项：</div>');
	$('#selectData').empty().append(html.join(''));
}
function removeSelectTag(key){
	delete selectData[key];
	dataGrid.dataGrid('resetSelection', key);
	$('#selectNum').html(--selectNum);
	$('#'+key+'_tags-input').remove();
}
function getSelectData(){
	
	return selectData;
}
function getData(){
	var sd="";
	$.each(selectData, function(key, value){
		sd=sd+"&"+key;
	});
	$.ajax({
		url : "${ctx}/ztGoodsquan/setData",
		type : "get",
		data : {
			"selectData" : sd
		},
		dataType : "json",
		contentType : "application/json",
		success : function(data) {
			//alert(data);
			//alert(data);
			//location = "${ctx}/ztGoodsquan/list?repage=" + Math.random();
			js.closeCurrentTabPage();
			
		},
		error : function(data) {
			toastr.error("fail");
		}
	});
	
}


function selectData(){
	$.ajax({
		url : "${ctx}/ztGoodsquan/getData",
		type : "get",
		data : {
			"selectData" : sd
		},
		dataType : "json",
		contentType : "application/json",
		success : function(data) {
			
			//alert(data);
		$.each(data, function(key, value){
			alert(key);
			dataGrid.dataGrid('setSelectRow', key);
		});
		initSelectTag(); 
			
		},
		error : function(data) {
			toastr.error("fail");
		}
	});
	}
</script>
